<!doctype html>
<html ng-app="baseDirective">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../build/common/base.css" rel="stylesheet">
<script type="text/javascript" src="../../build/common/base.js"></script>
<script type="text/javascript" src="../../build/common/ngEdit.js"></script>
<script type="text/javascript">
	var ComplateController = [ '$scope', 'baseService', 'ArrayToolService', function(scope, baseService, ArrayToolService) {
		scope.ArrayTool = ArrayToolService;
		scope.flowParam = window.passData;
		scope.flowParam.extendConf = {};
		scope.flowParam.extendConf.users = [];
		scope.selectUser = function() {
			CustUtil.openCustDialog("userSelector", null, function(data) {
				angular.forEach(data, function(item) {
					//根据SysIdentity拼装对象
					var newUser = {
						id : item.id,
						name : item.name,
						type : "user"//用户
					};
					var exist = false;
					angular.forEach(scope.flowParam.extendConf.users, function(user) {
						if (user.id == newUser.id) {
							exist = true;
						}
					});
					if (exist) {
						return;
					}
					scope.$apply(function() {
						scope.flowParam.extendConf.users.push(newUser);
					});
				});
			}, null, null, true);
		}
	} ];

	function isValidate() {
		if (AngularUtil.getScope().flowParam.extendConf.users.length == 0) {
			$.Toast.warning("请选择至少一个加签人");
			return false;
		}
		return true;
	}
</script>
</head>
<body class="panel success" ng-controller="ComplateController">
	<table class="form-table">
		<tr>
			<th>
				<span>加签人:</span>
				<span class="required">*</span>
			</th>
			<td>
				<span ng-repeat="user in flowParam.extendConf.users">
					<span class="btn btn-default fa-user">
						{{user.name}}
						<button href="javascript:void(0)" class="btn btn-link btn-default btn-xs" ng-click="ArrayTool.remove(user,flowParam.extendConf.users)">×</button>
					</span>
				</span>
				<a style="margin-left: 50px" class="btn btn-sm btn-primary fa-search" href="javascript:void(0)" ng-click="selectUser()">选择用户</a>
			</td>
		</tr>
	</table>
</body>
</html>